package com.zbj.data.jpa.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import java.io.Serializable;

/**
 * Student
 *
 * @author weigang
 * @create 2017-09-10
 **/
@Entity
//@Entity(name = "student")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
//@NamedNativeQuery  类似
@NamedQueries(value = {
		// 属性 name 中方法名是能解析出的查询语句 类似于 findByAge 等
		@NamedQuery(name = "Student.findById", query = "select s from Student s where s.name = ?1"), //   指定属性不行
		@NamedQuery(name = "Student.findByAddress", query = "select s from Student s where s.name = :address")
})
public class Student extends AbstractEntity implements Serializable {

	private static final long serialVersionUID = -2259402930003254149L;

	private String name;

	private Integer age;

	private String address;

	private String phone;

	@Column(name = "class_id")
	private Long classId;
}
